package com.buba.controller;

import com.buba.pojo.BranchInfo;
import com.buba.pojo.Message;
import com.buba.service.BranchInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author 杨柳
 * @title BranchInfo
 * @date 2024/4/18 10:10
 */
@RestController
@CrossOrigin(allowCredentials = "true"
        , originPatterns = "*")
public class BranchInfoController {
    @Autowired
    private BranchInfoService branchInfoService;

    @RequestMapping("/addBranchInfo")
    public Message addBranchInfo(@RequestParam Map<String, Object> map) {
        long count = branchInfoService.addBranchInfo(map);
        if (count == 0)
            return new Message(0, "添加错误");
        return new Message(1, "添加成功");
    }

    @RequestMapping("/selBranchInfo")
    public List<BranchInfo> selBranchInfo() {
        return branchInfoService.selBranchInfo();
    }

    @RequestMapping("/delBranchInfo")
    public Message delBranchInfo(@RequestParam("branchId") Integer branchId) {
        long count = branchInfoService.delBranchInfo(branchId);
        if (count == 0)
            return new Message(0, "删除错误");
        return new Message(1, "删除成功");
    }

    @RequestMapping("/updBranchInfo")
    public Message updBranchInfo(@RequestParam Map<String, Object> map) {
        long count = branchInfoService.updBranchInfo(map);
        if (count == 0)
            return new Message(0, "修改错误");
        return new Message(1, "修改成功");
    }


}
